//
//  BaseRequest.h
//  YYBG_IOS
//
//  Created by wyl on 2017/2/22.
//  Copyright © 2017年 wyl. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "AFNetworking.h"

@interface BaseRequest : NSObject

typedef void (^loadSuccess)(id data);
typedef void (^cacheSuccess)(id data);
typedef void (^loadFailure)(NSError *error);


typedef enum {
    PARAM_TYPE_FORM,
    PARAM_TYPE_BODY
} PARAM_TYPE;

/**
 *  post方法 (带文件上传功能)
 *
 *  @param url          url地址
 *  @param params       请求参数:NSDictionary或NSArray类型，无参数时传入nil
 *  @param type         参数模式，表单模式或body模式
 *  @param cacheSuccess 缓存回调block(主线程)
 *  @param success      成功回调block(主线程)
 *  @param failure      失败回调block(主线程)
 */
+(void) post:(NSString *) url parameters:(id) params  paramType:(PARAM_TYPE) type   success:(loadSuccess) success failure:(loadFailure) failure;


/**
 *  get方法
 *
 *  @param url          url地址
 *  @param cacheSuccess 缓存回调block(主线程)
 *  @param success      成功回调block(主线程)
 *  @param failure      失败回调block(主线程)
 */
+(void)  get:(NSString *) url   success:(loadSuccess) success failure:(loadFailure) failure;

/**
 *  put方法
 *
 *  @param url     url地址
 *  @param params  请求参数:NSDictionary或NSArray类型，无参数时传入nil
 *  @param success 成功回调block(主线程)
 *  @param failure 失败回调block(主线程)
 */
+(void)  put:(NSString *) url parameters:(id) params
     success:(loadSuccess) success
     failure:(loadFailure) failure;

/**
 *  delete方法
 *
 *  @param url     url地址
 *  @param params  请求参数:NSDictionary或NSArray类型，无参数时传入nil
 *  @param success 成功回调block(主线程)
 *  @param failure 失败回调block(主线程)
 */
+(void)  delete:(NSString *) url parameters:(id) params success:(loadSuccess) success failure:(loadFailure) failure;


/*!
 *   @author wyl, 16-07-22
 *
 *   @brief 图片文件上传
 *
 *   @param url       <#url description#>
 *   @param imageName <#imageName description#>
 *   @param params    <#params description#>
 *   @param type      <#type description#>
 *   @param image     <#image description#>
 *   @param success   <#success description#>
 *   @param failure   <#failure description#>
 */
+(void) post:(NSString *)url imageName:(NSString *)imageName parameters:(id)params paramType:(PARAM_TYPE) type image:(UIImage *)image success:(loadSuccess)success failure:(loadFailure)failure ;

//多图片上传
+(void) postImages:(NSString *)url imageName:(NSString *)imageName parameters:(id)params paramType:(PARAM_TYPE) type image:(NSArray *)image success:(loadSuccess)success failure:(loadFailure)failure;
@end
